package com.zhiyou100.crm.servlet.customerCategory;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.zhiyou100.crm.pojo.AdminBaseServlet;
import com.zhiyou100.crm.pojo.CustomerCategory;
import com.zhiyou100.crm.service.CustomerCategoryService;
import com.zhiyou100.crm.service.impl.CustomerCategoryServiceImpl;

/**
 * 客户分类
 */

@WebServlet("/customerCategory/list")
public class ListServlet extends AdminBaseServlet {
	private static final long serialVersionUID = 1L;
	CustomerCategoryService customerCategoryService = new CustomerCategoryServiceImpl();
	
	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		response.setContentType("text/html; charset=UTF-8");
		List<CustomerCategory> categories = customerCategoryService.queryAll();
		if(categories!=null) {
			request.setAttribute("categories", categories);
			request.getRequestDispatcher("/WEB-INF/view/customerCategory/list.jsp").forward(request, response);
		}else {
			request.getRequestDispatcher("/WEB-INF/view/customerCategory/list.jsp").forward(request, response);
		}

	}

}
